﻿@{
    Bundle("jquery_validate");
}
      
<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('@ID("#form")').validate({
            rules: {
                invoiceID: {
                    required: true,
                    digits: true
                },
                customerName: {
                    required: true
                },
                amount: {
                    required: true
                }
            }
        });
        jQuery('@ID("#txt_customer")').autocomplete({
            source: function (request, response) {
                jQuery.post('@Html.Raw(Url.Action(Loc.Act("Autocomplete").Ctrl("Customer")))', request, response);
            },
            minLength: 3,
            select: function (event, ui) {
                jQuery('@ID("#hidden_customer")').val(ui.item.id);
            }
        });
        jQuery.ajax({
            type: 'post',
            url: '@Url.Action(Loc.Act("Processors").Ctrl("Payment"))',
            dataType: 'json',
            success: function (rsp) {
                var ddl = jQuery('@ID("#ddl_processor")');
                ddl.empty();
                jQuery.each(rsp, function (k, v) {
                    ddl.append('<option value=' + v.id + '>' + v.value + '</option>');
                });
                ddl.change();
            }
        });
    });
</script>
<form id="@ID("form")" action="@Url.Action(Loc.Act("Place").Ctrl("Payment"))" method="post">
    <table>
        <tr>
            <td>
                <label>@T(Res.Name("Customer"))</label>
            </td>
            <td>
                <input id="@ID("hidden_customer")" type="hidden" name="customerID" value="0" />
                <input id="@ID("txt_customer")" type="text" name="customerName" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Processor"))</label>
            </td>
            <td>
                <select id="@ID("ddl_processor")" name="processorID"></select>
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Invoice"))</label>
            </td>
            <td>
                <input type="text" name="invoiceID" value="0" />
            </td>
        </tr>
        <tr>
            <td>
                <label>@T(Res.Name("Amount"), JDM.String(Svc.Localization.Currency.Code))</label>
            </td>
            <td>
                <input type="text" name="amount" value="@Svc.Price(Decimal.Zero)" />
            </td>
        </tr>
    </table>
    <ul class="bar toolbar">
        <li><button class="button" type="submit">@T(Res.In("Common").Of("Act").Name("Submit"))</button></li>
    </ul>
</form>
